<?php
  class NieuwsAction extends BaseAction
  {
      public function executeIndex()
      {
        $Nieuws = NieuwsPeer::getAllNieuws();
        core::$tpl->assign('nieuws', $Nieuws);
        $this->setContent('nieuws/nieuwsIndex.tpl');  
      }
      
      public function executeAddNieuws()
      {
         
          if(isset($_POST['submit']))
          {
              $obj = new Nieuws();
              $obj->setOnderwerp($_POST['onderwerp']);
              $obj->setTekst($_POST['bericht']);
              $obj->setDatum(date('Y-m-d H:i:s'));
              $obj->save();

              core::$tpl->assign('message', NEWS_ADDED_SUCCESFULL_MESSAGE);
              $this->executeIndex();  
          }
          else
          {
            $this->setContent('nieuws/nieuwsAddNieuws.tpl'); 
          }
      }
    
      public function executeEditNieuws()
      {
          if(isset($_POST['submit']))
          {
              $obj = NieuwsPeer::retrieveByPK($_GET['param']);
              $obj->setOnderwerp($_POST['onderwerp']);
              $obj->setTekst($_POST['bericht']);
              $obj->save();
              
              core::$tpl->assign('message', EDIT_NEWS_SUCCESFULL_MESSAGE);
              $this->executeIndex();  
          }
          else
          {   
              core::$tpl->assign('nieuws', NieuwsPeer::retrieveByPK($_GET['param']));
              $this->setContent('nieuws/nieuwsEditNieuws.tpl');
          }
      }      
     /* 
      public function executeEditTeam()
      {
          if(isset($_POST['submit']))
          {
              $obj = TeamPeer::retrieveByPK($_GET['param']);
              $obj->setNaam($_POST['name']);
              $obj->save();
              
              core::$tpl->assign('message', EDIT_TEAM_SUCCESFULL_MESSAGE);
              $this->executeIndex();  
          }
          else
          {   
              core::$tpl->assign('team', TeamPeer::retrieveByPK($_GET['param']));
              $this->setContent('team/teamEditTeam.tpl');
          }
      }
      */
      public function executeDeleteNieuws()
      {
          $Nieuws = NieuwsPeer::retrieveByPK($_GET['param']);
          
                $Nieuws->delete();
                core::$tpl->assign('message', DELETE_NEWS_SUCCESFULL_MESSAGE);
      
         
          $this->executeIndex();
      }
           
  }
?>
